<!--
 * @Descripttion: 商机进度
 * @version:
 * @Author: lehaixia
 * @Date: 2022-10-27 13:09:16
 * @LastEditors: lehaixia
 * @LastEditTime: 2022-11-02 16:46:41
-->
<template>
  <div class="content">
    <ComHeader title="商机进度" />
    <Progress :dict-data="dictData" :active="active" />
  </div>
</template>
<script>
import { getDictByPatchType } from '@/apis/dataDict'
import { getCategoryStageLine } from '@/apis/optyCategory'
import stepFinish from '@/assets/category/step-finish.png'
import Progress from '@/components/Progress'

export default {
  name: 'CustomerAdd',
  components: {
    Progress
  },
  data() {
    return {
      stepFinish,
      headHeight: 50,
      active: 0,
      dictData: []
    }
  },
  async created() {
    const { id, stage, dictTypeCode } = this.$route.query
    const list = await getCategoryStageLine(id)

    const dictTypeCodes = [dictTypeCode]
    const dictData = await getDictByPatchType({ dictTypeCodes })
    this.dictData = dictData[dictTypeCode]

    this.dictData.forEach((v, i) => {
      list.forEach(m => {
        if (v.dictCode === m.afterStage) {
          const time = m.createTime
          const desc = m.createBy + '将品类节点流转至' + v.dictName
          if (i > 0) {
            this.dictData[i - 1].time = time
            this.dictData[i - 1].desc = desc
          }
        }
      })
    })

    const active = this.dictData.findIndex(v => v.dictCode === stage)
    if (active !== -1) {
      this.active = active
    }
  },
  methods: {
  }
}
</script>
<style lang="less" scoped>

</style>
